import {lawyerSettled, lawyerList, lawyerDetail, lawyerInfo, lawyerEdit, lawyerOrder,updateOrderState} from '@/api/lawer/lawer'


const lawyer = {
    mutations: {

    },

    actions: {
        //律师入驻
        LawyerSettled({ commit }, data) {
            const address = data.address
            const certificate = data.certificate
            const company = data.company
            const info = data.info
            const judgment = data.judgment
            const name = data.name
            const num = data.num
            const phone = data.phone
            const professionalPhoto = data.professionalPhoto
            const qrCode = data.qrCode
            return new Promise((resolve, reject) => {
                lawyerSettled({ address, certificate, company, info, judgment, name, num, phone, professionalPhoto, qrCode }).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //律师列表
        LawyerList({ commit }, data) {
            const page = data.page
            const size = data.size
            return new Promise((resolve, reject) => {
                lawyerList({ page, size }).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //律师详情
        LawyerDetail({ commit }, id) {
            return new Promise((resolve, reject) => {
                lawyerDetail(id).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //根据用户id查询律师信息
        LawyerInfo({ commit }, id) {
            return new Promise((resolve, reject) => {
                lawyerInfo(id).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //编辑律师信息
        LawyerEdit({ commit }, data) {
            return new Promise((resolve, reject) => {
                lawyerEdit(data).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //获取当前律师的订单
        LawyerOrder({ commit },{current,size,orderState}) {
            return new Promise((resolve, reject) => {
                lawyerOrder({current,size,orderState}).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        //修改订单状态
        UpdateLawyerOrder({ commit }, {orderId, orderState}) {
            return new Promise((resolve, reject) => {
                updateOrderState({orderId, orderState}).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        }
    }
}

export default lawyer;

